<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="admin.*"%>
<%
	request.setCharacterEncoding("utf-8");
	String action=request.getParameter("submit");
	if(action!=null&&action.equals("提交")){
		String author=request.getParameter("author");
		String title=request.getParameter("title");
		String time=request.getParameter("time");
		String describe=request.getParameter("describe");
		String cover=request.getParameter("cover");
		String blogdata=request.getParameter("blogdata");
		Setblog sb=new Setblog();
		String result=sb.setdata(author, title, time, describe, cover, blogdata);
		out.println("<script language='JavaScript'>alert('"+result+"');</script>");
	}
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ROUD文本编辑器</title>
    <link rel="icon" type="image/png" href="static\\img\\tx.png" type="image/x-ico"\>
    <link rel="stylesheet" href="Editor/css/style.css" />
    <link rel="stylesheet" href="Editor/css/editormd.css" />
    <style>
        *{
            padding:0;
            margin:0;
        }
        body{
            min-height:100vh;
            min-width:100vh;
        }
        #form{
            text-align:left;
            margin-left: 30px;
            margin-top: 20px;
        }
        #empty{
            height: 20px;
        }
        @font-face { 
            font-family: "roud666";
            src: url("static\\font\\Harley.ttf"); 
        }
        #headBox{
            position: relative;
            width: 100%;
            height: 90px;
            line-height:90px;
            text-align:center;
            background-image: linear-gradient(120deg,rgb(140, 0, 255),rgb(1, 253, 220));
            color: rgb(255, 255, 255);
            font-size:30px;
            font-family:"roud666";
            font-weight:300;
        }
        #btn{
            height: 30px;
            width: 50px;
            background-color:rgb(0, 46, 250,0.6);
            color: white;
            margin-right: 100px;
            cursor: pointer;
        }

    </style>

</head>
<body>
    <div id="headBox">Always believe in beauty</div>
    <form method="post" id="form">
        <label for="author">作者:</label>
        <input type="text" id="author" style="width: 500px;" name="author"/>
        <br><h6 id="empty"></h6>
        <label for="title">标题:</label>
        <input type="title" id="title" style="width: 500px;" name="title"/>
        <br><h6 id="empty"></h6>
        <label for="time">日期:</label>
        <input type="date" id="time" style="width: 500px; text-align:center;" name="time"/>
        <br><h6 id="empty"></h6>
        <label for="describe">简介:</label>
        <input type="textarea" id="describe" style="width: 500px;height: 100px;" name="describe"/>
        <br><h6 id="empty"></h6>
        <label for="cover">封面:</label>
        <input type="text" id="cover" style="width: 500px;" name="cover"/>
        <br><h6 id="empty"></h6>
        <input type="text" id="hiddeninput" style="width: 500px;display:none;" name="blogdata"/>
    
    <!-- Editor容器... -->
        <div id="test-editormd">
            <textarea id="content" name="content" style="display:none;"></textarea>
        </div>
    <!-- Editor容器... -->
        
        <input type="button" id="btn" class="save" value="保存" name="save"/>
        <input type="reset" id="btn" class="reset" value="重置" name="reset"/>
        <input type="submit" id="btn" class="submit" value="提交" name="submit"/>
        <input type="button" id="btn" class="quit" value="退出" name="quit"/>
        
    </form>

    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="Editor/js/editormd.min.js"></script>
    <script type="text/javascript">

        var testEditor;
        $(function() {
            testEditor = editormd("test-editormd", {
                width   : "98%",
                height  : 300,
                syncScrolling : "single",
                path    : "Editor/lib/", //依赖lib文件夹路径    
                emoji : true,
                taskList : true,
                tocm     : true,
                imageUpload: true,
                imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                imageUploadURL: "imageUpload"		//上传图片控制器Mapping
            });        
        });
    </script>
    <!-- <script>
        //重置

    </script> -->
    <script>
        var save=document.querySelector(".save");
        var hiddeninput=document.querySelector("#hiddeninput");
        save.addEventListener("click",function(){
            var editorHTML=document.querySelector(".editormd-preview-container").innerHTML;
            var reg=/\n/g;
            var resultHtml=editorHTML.replace(reg,"");
            // console.log(resultHtml);
            hiddeninput.value=resultHtml;
        })
        
        var quit=document.querySelector(".quit");
        quit.addEventListener("click",function(){
            var r=confirm("确认退出?");
            if(r==true){
                location.href="manage.jsp";
            }
        })
    </script>
    

</html>
